<template>
  <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
    <van-list
      class="more-main"
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <div class="more-item-title">{{title}}</div>
      <!-- <van-cell v-for="item in list" :key="item" :title="item" /> -->
      <div class="more-body">
        <div
          class="more-item"
          v-for="(item,index) in dataArr"
          :key="index+'_'+item.id"
          :title="item"
        >
          <img class="more-item-img" :data-src="item.image" :src="item.image" lazy="loaded">
          <p class="more-item-name" :title="item.storeInfo">{{item.storeName}}</p>
          <p class="more-item-price">
            <span class="code">￥</span>
            <span class="mallPrice">{{item.price}}</span>
            <span class="price-min">{{item.vipPrice}}</span>
          </p>
        </div>
      </div>
    </van-list>
  </van-pull-refresh>
</template>
<script>
import { page } from "@/assets/js/mixin";

export default {
  name: "MoreProduct",
  mixins: [page],
  props: {
    title: {
      type: String,
      default: ""
    },
    url: {
      type: String,
      required: true
    }
  },
  data() {
    return {
      //   finished: false,
      refreshing: false
    };
  },
  methods: {
    onLoad() {
      this.locked();
      this.Api.callMethod({ url: this.url,params:{},suffix:"/1/10" }).then(({code,data}) => {
        if (code == "200") {
          this.setNewData(data.list);
          this.setTotal(data.total);
        }else{
          this.setNewData(null);
          this.setTotal(0)
        }
        this.unLocked();
      });
    },
    onRefresh() {
      // 清空列表数据
      //   this.finished = false;
      // 重新加载数据
      // 将 loading 设置为 true，表示处于加载状态
      //   this.loading = true;
      //   this.onLoad();
    }
  },
  created() {
    console.log("this", this);
  },
  computed: {
    finished: function() {
      return !!this.total && this.getCurrentStart() >= this.total;
    }
  }
};
</script> 
<style lang="less" scoped>
.more-item-title {
  background: #ededed;
  height: 40px;
  line-height: 40px;
  text-align: center;
  color: #e0322b;
  font-size: 15px;
  position: relative;
}
.more-body {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  background: #eee;
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
}
.more-item {
  float: left;
  -webkit-box-flex: 0;
  -ms-flex: 0 0 45.5%;
  flex: 0 0 49.9%;
  width: 50% !important;
  margin-right: 0 !important;
  margin-top: 1px;
  overflow: hidden;
  text-align: center;
  background: #fff;
  padding: 0.4rem 0px;
  .more-item-img {
    width: 90%;
    height: 3.5rem;
    vertical-align: middle;
  }
  .more-item-name {
    padding: 5px 7.5px 0 7.5px;
    color: #e0322b;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .more-item-price {
    color: #e0322b;
    padding-top: 5px;
    .code {
      font-size: 13px;
    }
    .mallPrice {
      font-size: 15px;
      color: #e0322b;
      font-weight: 700;
    }
    .price-min {
      font-size: 12px;
      text-decoration: line-through;
      color: #999;
      display: inline-block;
      margin-left: 5px;
    }
  }
}
</style>

